package edu.ycxy.poetry.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.ycxy.poetry.entity.DjList;
import edu.ycxy.poetry.vo.AddDjVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author @xin
 * @createDate 2022/3/14
 * @Description
 */
@Repository
public interface DjListMapper extends BaseMapper<DjList> {

    //查询典籍的所有内容
    @Select("select * from vab_dj_list")
    List<DjList> selectListByDjList();

    //根据古籍的id查询古籍的内容
    @Select("select * from vab_dj_list where id=#{id}")
    DjList selectOneById(Integer id);

    //根据古籍的类型名查找古籍符合条件的内容

    @Select("select * from vab_dj_list where type like CONCAT('%',#{type},'%')")
    List<DjList> selectListByType(String type);

    //插入古籍
    @Insert("insert into vab_dj_list(title,info,zuozhe,type,body) values (#{title},#{info},#{zuozhe},#{type},#{info})")
    Integer addDjInfo(AddDjVo addDjVo);

    //根据古籍名查询内容
    @Select("select * from vab_dj_list where title=#{title}")
    DjList findByTitle(String title);
}
